home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Re: sizeof() question >>> :)
- Date: 14 Apr 1996 14:45:27 -0700
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4krrlnINN7o5@keats.ugrad.cs.ubc.ca>
- References: <1996Apr12.061927@topaz> <31714828.1574068@news.linex.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <31714828.1574068@news.linex.com>,
- Marty Fried <mfried@linex.com> wrote:
- >Once upon a time (OK, it was 12 Apr 96 06:19:27 +1000),
- >naderr@topaz.cqu.edu.au wrote:
- >
- >>Hi,
- >>
- >>How can I get, with a pointer, the sizeof of an array that is
- >>pointed by the pointer ? (No it's not a tounge twister :)
- >>
- >> while (!done) {
- >> ch = getchar();
- >> if (cp - *ct < sizeof(XXXXXXX)-1) {
- >> *cp++ = ch;
- >> } else {
- >> beep();
- >> }
- >> }
- >
- >You can't do it. The only thing you could do is to use exception
- >handling, and copy the characters within a try block until you get
- >an exception. I'm not sure if even that will give you the exact size
- >or work all the time, although it will prevent an exception from
- >causing the program to crash.
-
- Oh god. I've heard enough overly complex answers to this simple problem from
- comp.lang.c++ to convince me that it might as well be re-written into
- interpreted Lisp, and executed on Vax emulator...
-
- Let's no lose sight of the fact that all the chap wants to do is read some text
- fields into character arrays: something that has been frequently done since the
- days of punched cards and hardcopy terminals.
-